home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interapplication Communication / AE Tools / AE Sub-Descriptors Library 1.0 / AESubDescs.h < prev    next >
Encoding:
Text File  |  1992-03-16  |  2.2 KB  |  61 lines  |  [TEXT/KAHL]

  1. // AESubDescs.h
  2. //
  3. // A high-efficiency way to examine AEDescs. Everything is done in place, without any
  4. // copying of data, which avoids most of the overhead of the Apple Event Manager.
  5. //
  6. // By Jens Alfke; Copyright ©1992 Apple Computer. All Rights Reserved.
  7.  
  8.  
  9. #pragma once                                        /* For THINK C users */
  10. #ifndef __AESUBDESCS__
  11. #define __AESUBDESCS__                                /* For poor MPW users :) */
  12.  
  13. #include <AppleEvents.h>
  14.  
  15. enum{                                                // Error code
  16.     errAEListIsFactored        = -1760                        // I cannot get data from factored lists
  17. };
  18.  
  19.  
  20. typedef struct {
  21.     DescType    subDescType;        // Type of this subDesc. You may read this field.
  22.     Handle        dataHandle;            // Handle to main (outer) descriptor. Private.
  23.     long        offset;                // Offset into main descriptor where subDesc starts. Private.
  24. } AESubDesc;
  25.  
  26.  
  27. pascal void
  28.     AEDescToSubDesc( const AEDesc*, AESubDesc* );                    // Create subDesc on desc
  29. pascal OSErr
  30.     AESubDescToDesc( const AESubDesc*, long desiredType, AEDesc* );    // Copy subDesc to new desc
  31.  
  32. pascal DescType
  33.     AEGetSubDescType( const AESubDesc* );                            // Same as ->subDescType
  34. pascal void*
  35.     AEGetSubDescData( const AESubDesc*, long *length );                // Invalid once dataHandle moves
  36.  
  37. // Use AEGetSubDescBasicType to see if a descriptor is a coerced record. If it is, the result
  38. // type will be typeAERecord ('reco'). Otherwise it will be the same as the regular subDescType.
  39. // This call allocates memory; an error may be returned if there wasn't enough free.
  40.  
  41. pascal OSErr
  42.     AEGetSubDescBasicType( const AESubDesc*, DescType* basicType );
  43.  
  44. // The list-oriented calls that follow make no attempt to check whether the input SubDesc really
  45. // is a list or a record.
  46. // This lets the you directly access coerced records, but you will probably die in a big way
  47. // if the descriptor isn't a record at all. Call AEGetSubDescBasicType beforehand (and see if
  48. // the basic type is typeAEList or typeAERecord) if you're cautious.
  49.  
  50. pascal long
  51.     AECountSubDescItems( const AESubDesc* );
  52.  
  53. // In these next two calls, it's okay if newSD == sd; sd will be overwritten with the new subDesc.
  54.     
  55. pascal OSErr
  56.     AEGetNthSubDesc( const AESubDesc* sd, long index,
  57.                      AEKeyword* keyIfAny, AESubDesc* newSD ),
  58.     AEGetKeySubDesc( const AESubDesc* sd, AEKeyword,
  59.                      AESubDesc* newSD );
  60.  
  61. #endif